package org.example.messagewallplus.controller;

import org.example.messagewallplus.model.MessageInfo;
import org.example.messagewallplus.service.MessagewallSevice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

@CrossOrigin
@RequestMapping("/messagewall")
@Controller
public class MessagewallController {
    @Autowired
    MessagewallSevice sevice;

    @RequestMapping("")
    public String wall() {
        return "/messagewall.html";
    }

    @ResponseBody
    @RequestMapping("/getList")
    public List<MessageInfo> getMessageInfo() {
        return sevice.getMessageInfo();
    }

    @ResponseBody
    @RequestMapping("/publish")
    public boolean publish(@RequestBody MessageInfo messageInfo) {
        var jude = sevice.publish(messageInfo);
        System.out.println(jude);
        return jude;
    }
}

